import 'package:flutter/material.dart';
import 'package:flutter_structure/app/localization/localization_controller.dart';
import 'package:flutter_structure/app/theme/app_colors.dart';
import 'package:flutter_structure/common/dialog/prompt.dart';
import 'package:flutter_structure/common/widgets/status_bar.dart';
import 'package:flutter_structure/modules/home/views/open_pro.dart';
import 'package:flutter_structure/modules/home/views/setting_theme.dart';
import 'package:get/get.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  final langController = Get.find<LanguageController>();
  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return StatusBar(
      statusBarColor: theme.scaffoldBackgroundColor, 
      statusBarIconBrightness: theme.brightness == Brightness.dark ? Brightness.light : Brightness.dark, 
      child: SafeArea(
        child: Center(
          child: Column(
            children: [
              ElevatedButton(
                onPressed: () {
                  SettingTheme.show();
                },
                child: Text('change_theme'.tr),
              ),
              ElevatedButton(
                onPressed: () {
                  langController.switchLanguage(
                    langController.locale.value.languageCode == 'en' ? 'zh' : 'en',
                  );
                },
                child: Text('change_language'.tr),
              ),
              ElevatedButton(
                onPressed: () {
                  Prompt.show(message: "已加入提示 开始提示", theme: theme , position: "bottom");
                },
                child: Text('show_prompt'.tr),
              ),
              ElevatedButton(
                onPressed: () {
                  OpenPro.show(theme: theme.extension<AppColors>()!);
                },
                child: Text('open_pro_pop'.tr),
              ),
            ],
          ),
        ),
      )
    );
  }
}